<form action="" class="top30 state2W">
    <table class="tableNew tableRaius chafeng chafengList" for="" border="0" cellspacing="0" cellpadding="0" style="border-collapse:separate;border-spacing: 0;">
        <tr>
            <td>抵押物抵押顺序</td>
            <td >
                <input style="padding-left: 0;" type="text" readonly="readonly" name="" id="" title="内容提示" value="<?= !empty($mortgageStateTable['mortgage_order'])?$mortgageStateTable['mortgage_order']:'';?>" />
            </td>
        </tr>
        <tr>
            <td>是否首押</td>
            <td>
                <input style="padding-left: 0;" type="text" readonly="readonly" name="" id="" title="内容提示" value="<?= !empty($mortgageStateTable['is_first_mortgage'])?Yii::$app->params['IsFirstMortgage'][$mortgageStateTable['is_first_mortgage']]['name']:'';?>" />
            </td>
            
        </tr>
        <tr>
        	<td>后续抵押情况</td>
            <td>
            	<pre><?= !empty($mortgageStateTable['mortgage_future'])?$mortgageStateTable['mortgage_future']:'';?></pre>
            </td>
        </tr>
        <tr>
            <td>抵押情况描述</td>
            <td >
            <pre><?= !empty($mortgageStateTable['mortgage_situation'])?$mortgageStateTable['mortgage_situation']:'';?></pre>
                <!--<input style="padding-left: 0;color: #333333;" type="text" readonly="readonly" name="" id="" title="内容提示" value="<?= !empty($mortgageStateTable['mortgage_situation'])?$mortgageStateTable['mortgage_situation']:'';?>" />-->
            </td>
        </tr>
    </table>
</form>

<form action="" class="radioYn state2Edit" style="display: none;">
    <table class="tableNew tableRaius editTable tableEdit5 top30" for="" border="0" cellspacing="0" cellpadding="0" style="border-collapse:separate;border-spacing: 0;border: none;">
        <input type="text" hidden value="<?= !empty($ppseid)?$ppseid:0;?>" id="ppseid2">
        <input type="text" hidden value="<?= !empty($mortgageStateTable['id'])?$mortgageStateTable['id']:'';?>" id="mortgage_id">
        <tr>
            <td>抵押物抵押顺序</td>
            <td>
                <textarea id="mortgage_order" class="textarea-edit" class="textarea-edit"><?= !empty($mortgageStateTable['mortgage_order'])?$mortgageStateTable['mortgage_order']:'';?></textarea>
            </td>
        </tr>
        <tr>
            <td>是否首押</td>
            <td>
                <label for="ynleiYes">
                    <span class="<?=!empty($mortgageStateTable['is_first_mortgage'])&&$mortgageStateTable['is_first_mortgage']==1?'yesActive':'noActive'?>">是</span>
                    <input type="radio" checked="checked" class="yes" data-val="1"  name = 'ynlei' id ="ynleiYes" />
                </label>
                <label for="ynleiNo">
                    <span class="<?=!empty($mortgageStateTable['is_first_mortgage'])&&$mortgageStateTable['is_first_mortgage']==2?'yesActive':'noActive'?>">否</span>
                    <input type="radio"  class="no" data-val="2" name = 'ynlei' id="ynleiNo" />
                </label>
            </td>
        </tr>
        <td>后续抵押情况</td>
        <td>
            <textarea name="" rows="" class="textarea-edit" cols="" id="mortgage_future"><?= !empty($mortgageStateTable['mortgage_future'])?$mortgageStateTable['mortgage_future']:'';?></textarea>
        </td>
        <tr>

        </tr>
        <tr>
            <td>抵押情况描述</td>
            <td>
                <textarea name="" rows="" cols="" class="textarea-edit" id="mortgage_situation"><?= !empty($mortgageStateTable['mortgage_situation'])?$mortgageStateTable['mortgage_situation']:'';?></textarea>
            </td>
        </tr>
    </table>
    <div class="cancelInConfirm clearfix">
        <input id="ajaxMortgageState" class="cancelInConfirmActive" type="button" value="保存" />
        <input id='cancel2' type="button" value="取消" />
    </div>
</form>
	<!-- textarea 高度设置对比div -->
	
	<div style="max-height: 1px; overflow: hidden;">
		
		<div id="d1" style="visibility:hidden;min-height: 80px;"></div>
	
	</div>
<script>
    $(function () {
    	// textarea 高度展示问题
	    $(".textarea-edit").keyup(function(){
	           console.log(111111111);
	      var val = $(this).val();
	      $("#d1").html("<pre>" +val+" "+"</pre>");
	      var h = $("#d1").height() ;
	      $(this).height(h);
	    });
        var mortgage_id = $("#mortgage_id").val();
        $("#ajaxMortgageState").click(function () {
            var mortgage_situation = $("#mortgage_situation").val();
            var mortgage_future = $("#mortgage_future").val();
            var is_first_mortgage = $("#ynleiNo").prev().attr('class')=='yesActive'?2:1;
            var mortgage_order = $("#mortgage_order").val();
            var ppseid2 = $("#ppseid2").val();
            var url = '/project/ajax-save-mortgage-condition-table-project';
            var Pdtat = {
                'mortgage_situation':mortgage_situation,
                'mortgage_future':mortgage_future,
                'is_first_mortgage':is_first_mortgage,
                'mortgage_order':mortgage_order,
                'mortgage_id':mortgage_id,
                'ppseid':ppseid2,
            };
            $.post(url,{data:Pdtat,mortgage_id:mortgage_id},function (res) {
                if(res){
                    layer.msg('保存成功')
                    state2W();
                }else{
                    layer.msg('保存失败')
                }
            })
        })
        //-----------------渲染无编辑页面--------------------
        function state2W() {
            var ppseid2 = $("#ppseid2").val();
            $.get('/project/get-mortgage-view-table',{'project_id':project_id,'postion':2,'mortgage_id':mortgage_id,"ppseid":ppseid2},function (res) {
                $(".state2Edit").remove();
                $(".state2W").remove();
                $("#state2").before(res);
                $("#getState2").show();
            })
        }
        //-----取消保存按钮
        $("#cancel2").click(function () {
            var ppseid2 = $("#ppseid2").val();
            $.post('/project/ajax-un-lock',{'postion':111,'ppesid':ppseid2,},function (res) {
                var JSONData = JSON.parse(res)
                if (JSONData.code == 200){
                    layer.msg(JSONData.message);
                }else{
                    layer.msg(JSONData.message);
                }
            });
            $(".state2Edit").hide();
            $(".state2W").show();
        })
        //----是否首押
        $("#ynleiYes").click(function () {
            $("#ynleiYes").prev().attr('class','yesActive')
            $("#ynleiNo").prev().attr('class','noActive')
        })
        $("#ynleiNo").click(function () {
            $("#ynleiYes").prev().attr('class','noActive')
            $("#ynleiNo").prev().attr('class','yesActive')
        })
    })
</script>